import request from '@/utils/http'

const PATH = '/statics/agent'

// 获取概览总收入
export const getOverviewIncome = (data: { userId: number | string }) =>
	request({ url: `${PATH}/web/total/income`, method: 'POST', data })
// c端收入
export const getCIncome = (data: { userId: number | string }) =>
	request({ url: `${PATH}/web/income`, method: 'POST', data })
// 被邀请玩家
export const getInvitedPlayer = (data: {
	userId: number | string
	inviteName?: string
	sortBy?: string
}) => request({ url: `${PATH}/web/invite/user`, method: 'POST', data })

export const getUpgradeRule = (params: any) =>
	request({ url: `${PATH}/upgrade-rule`, method: 'GET', params })

// 获取活动列表
export interface InviteLinkUserDetailData {
	inviteLinkCount: number // 已创建活动数量
	registerUserCount: number // 注册用户数量
	totalIncome: number // 总收入
	list: InviteLinkWebUserDetailVO[] // 链接详情
}

export interface InviteLinkWebUserDetailVO {
	id: number // 链接ID
	registerCount: number // 注册用户数
	rechargeCount: number // 充值玩家数量
	totalRecharge: number // 总充值金额
	rebateRate: number // 返点率
	feeRate: number // 介绍费率
	inviteCode: string // 邀请码
}

export const getInviteLinkUserDetail = (params: { userId: number }) =>
	request({ url: `/statics/invite/link/user/detail`, method: 'GET', params })

// 创建活动
export const createCampaign = (data: { userId: number; name: string; inviteCode: string }) => {
	return request({
		url: `/statics/invite/link/save/code`,
		method: 'POST',
		data
	})
}

// 置顶活动
export const topCampaign = (data: { userId: number; id: number }) =>
	request({
		url: `/statics/invite/link/top`,
		method: 'POST',
		data
	})

// 生成邀请码
export const generateInviteCode = () =>
	request({
		url: `/statics/invite/link/generate/code`,
		method: 'GET'
	})

// 活动-获取活动名下拉框
export const getCampaignName = (params: { userId: number }) =>
	request({
		url: `/statics/invite/link/name/byUser`,
		method: 'GET',
		params
	})

// 领取待领取金额-C端
export const receiveAmount = (data: { userId: number | string }) =>
	request({
		url: `/statics/agent/receive/amount`,
		method: 'POST',
		data
	})

// 获取用户币种列表
export interface CoinListItem {
	userId: number
	currency: string
	receivedAmount: number
	toBeReceivedAmount: number
}

export const getCoinList = (data: { userId: number }) =>
	request({
		url: `/statics/agent/coin/list`,
		method: 'POST',
		data
	})
